package ModelLayer;
import java.util.*;
/**
 * Write a description of class StaffList here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class StaffList
{
    private static StaffList instance = null;
    private HashMap<Integer, Staff> allStaff;

    /**
     * Constructor for objects of class StaffList
     */
    private StaffList()
    {
        allStaff = new HashMap<Integer, Staff>();
    }
    
    public static StaffList getInstance() { 
        if(instance == null) 
            instance = new StaffList(); 
        return instance; 
    }
    
    public void addStaff(Staff staff){
        allStaff.put((Integer)staff.getId(), staff);
    }
    
    public boolean deleteStaffMember(int id){
        return (allStaff.remove(id) !=null);
    }
    
    public Staff getStaffMember(int id){
        if(allStaff.containsKey(id)){
            return allStaff.get(id);
        }
        return null;
    }
    
    public Staff getStaffMember(String username)
    {
        for(Staff staff : allStaff.values())
            if(staff.getUsername().equals(username)) return staff;
            
        return null;
    }
}
